<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 定义约数(除本身）之和函数
        var foo = function fun(a) {
            var sum = 0;
            for (i = 1 ; i < a ; i++) {
                if (a % i == 0){
                    sum += i;
                }
            }
            return sum;
        };
        // 调用函数
        for (b = 1 ; b <= 2000 ; b++) {
            // 计算b的约数和(b的约数和赋值给a)
            var a = foo(b);
            if (foo(a) == b && b != a) { // a的约数和等于b且a和b不是同一个数
                console.log(a + "和" + b + "是一对亲密数");
            }
        }
    </script>
</head>
<body>
    
</body>
</html>